package com.sv.ues.fia.tourismosv;

import sv.ues.fia.tourismosv.R;
import sv.ues.fia.tourismosv.R.layout;
import sv.ues.fia.tourismosv.R.menu;
import sv.ues.fia.tourismosv.model.Comentario;
import sv.ues.fia.tourismosv.model.Puntuacion;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class ComentarActivity extends Activity {
	
	CrearBaseTurismo helper;
	EditText editComment;
	String id;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_comentar);
		helper = new CrearBaseTurismo(this);
		editComment = (EditText) findViewById(R.id.editCommentLugar);
		Bundle bundle = getIntent().getExtras();
		id = bundle.getString("idLugar");
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.comentar, menu);
		return true;
	}
	
public void insertarComentario(View v) {
		
		String com=editComment.getText().toString();

		String regInsertados;
		
		Comentario comment = new Comentario();
		comment.setIdlugar(Integer.parseInt(id));
		comment.setComentario(com);
		helper.abrir();
		regInsertados=helper.insertar(comment);
		helper.cerrar();
		Intent intent2 = new Intent(getApplicationContext(), MenuPrincipalActivity.class);
		startActivity(intent2);
		Toast.makeText(this, regInsertados, Toast.LENGTH_SHORT).show();
		finish();
	}

}
